import { formatDate } from '@/utils/formatTime'

export const useSearchForm = [
  // {
  //   field: 'id',
  //   label: '活动编号',
  //   component: 'Input'
  // },
  {
    field: 'name',
    label: '活动名称',
    component: 'Input'
  },
  {
    field: 'status',
    label: '活动状态',
    component: 'Select',
    options: [
      { label: '开启', value: 1 },
      { label: '关闭', value: 0 }
    ]
  },
  {
    field: 'createTime',
    label: '创建时间',
    component: 'DatePicker',
    type: 'daterange',
    startPlaceholder: '开始日期',
    endPlaceholder: '结束日期'
  }
]

export const columns = [
  {
    prop: 'id',
    label: '活动编号',
    align: 'center'
  },
  {
    prop: 'name',
    label: '活动名称',
    align: 'center'
  },
  {
    prop: 'status',
    label: '活动状态',
    align: 'center',
    formatter: (row: any) => {
      return row.status === 1 ? '开启' : '关闭'
    }
  },
  {
    prop: 'startTime',
    label: '活动时间',
    align: 'center',
    formatter: (row: any) => {
      return `${formatDate(row.startTime, 'YYYY-MM-DD HH:mm:ss') || '-'} ~ ${formatDate(row.endTime, 'YYYY-MM-DD HH:mm:ss') || '-'}`
    }
  },
  {
    prop: 'createTime',
    label: '创建时间',
    align: 'center',
    formatter: (row: any) => {
      return formatDate(row.createTime, 'YYYY-MM-DD HH:mm:ss')
    }
  }
]

export const actionColumn = {
  width: 200,
  align: 'center',
  label: '操作',
  prop: 'actions',
  fixed: 'right'
}

export const goodsColumns = [
  { label: '商品名称', prop: 'name' },
  {
    label: '商品图',
    prop: 'picUrl',
    slots: {
      name: 'picUrl'
    }
  },
  {
    label: '商品价格',
    prop: 'price',
    formatter: (row: any) => {
      return row.price || row.price === 0 ? row.price / 100 + '元' : '-'
    }
  },
  {
    label: '市场价',
    prop: 'marketPrice',
    formatter: (row: any) => {
      return row.marketPrice || row.marketPrice === 0 ? row.marketPrice / 100 + '元' : '-'
    }
  },
  {
    label: '经验值',
    prop: 'experience',
    slots: {
      name: 'experience'
    }
  },
  {
    label: '积分',
    prop: 'points',
    slots: {
      name: 'points'
    }
  }
]
